﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Aop_AspectCore.Core
{
    public class Person
    {
        [CustomInterceptor]
        public virtual void Say(string msg)
        {
            Console.WriteLine("service calling..." + msg);
        }


        [HystrixCommand(nameof(HelloFallBackAsync))]
        public virtual async Task<string> HelloAsync(string name)
        {
            return await Task.Run(() =>
            {
                Console.WriteLine("hello" + name);
                throw new Exception();
                return "ok";
            });
        }
        [HystrixCommand(nameof(Hello2FallBackAsync))]
        public virtual async Task<string> HelloFallBackAsync(string name)
        {
            return await Task.Run(() =>
            {
                Console.WriteLine("执行失败" + name);
                throw new Exception();
                return "fail";
            });
        }
       
       
        public virtual async Task<string> Hello2FallBackAsync(string name)
        {
            return await Task.Run(() =>
            {
                Console.WriteLine("Hello 降级 2" + name);
                return "fail_2";
            });
        }
        [HystrixCommand(nameof(AddFall))]
        public virtual int Add(int i, int j)
        {
            String s = null;
            s.ToString();
            return i + j;
        }

        public int AddFall(int i, int j)
        {
            return 0;
        }



    }
}
